package com.qzw.security.service.entity;

import com.qzw.common.service.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.Entity;
import java.util.Date;
import java.util.Set;

/**
 * @author ：quziwei
 * @date ：Created in 2020/6/2 8:56 上午
 * @description：权限：用户表
 */
@Getter
@Setter
@ToString
@Entity
@DynamicUpdate
@DynamicInsert
@Inheritance(strategy = InheritanceType.JOINED)
public class SysUser extends BaseEntity<Integer> {

    @Column(nullable = false,unique = true)
    private String username;//用户名

    @Column(nullable = false)
    private String password;//密码

    @CreationTimestamp
    private Date createTime;//创建时间

    @ColumnDefault("0")
    private Byte status;//用户状态

    @ManyToMany
    @JoinTable(name = "sys_user_role", joinColumns = {@JoinColumn(name = "user_id")}, inverseJoinColumns = {@JoinColumn(name = "role_id")})
    private Set<SysRole> roles;

}
